From a2fd27001f3694238fae14d4ce3979024ce1e6cc Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Thu, 13 Jan 2005 10:01:42 +0000 Subject: [PATCH] bitkeeper revision 1.1159.170.92 (41e64706rQEeEkbb1iQ8WhbAgZNBFQ) Clean up string functions (memcpy/memset). --- xen/common/string.c | 3 ++- xen/include/asm-x86/x86_32/string.h | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/xen/common/string.c b/xen/common/string.c index bf9595d75b..c49d32deb0 100644 --- a/xen/common/string.c +++ b/xen/common/string.c @@ -391,6 +391,7 @@ char * bcopy(const char * src, char * dest, int count) } #endif +#ifndef __HAVE_ARCH_MEMCPY /** * memcpy - Copy one area of memory to another * @dest: Where to copy to @@ -400,7 +401,6 @@ char * bcopy(const char * src, char * dest, int count) * You should not use this function to access IO space, use memcpy_toio() * or memcpy_fromio() instead. */ -#undef memcpy void * memcpy(void * dest,const void *src,size_t count) { char *tmp = (char *) dest, *s = (char *) src; @@ -410,6 +410,7 @@ void * memcpy(void * dest,const void *src,size_t count) return dest; } +#endif #ifndef __HAVE_ARCH_MEMMOVE /** diff --git a/xen/include/asm-x86/x86_32/string.h b/xen/include/asm-x86/x86_32/string.h index 27fbb4d035..43fad09eea 100644 --- a/xen/include/asm-x86/x86_32/string.h +++ b/xen/include/asm-x86/x86_32/string.h @@ -206,7 +206,7 @@ return (to); * This looks horribly ugly, but the compiler can optimize it totally, * as the count is constant. */ -static inline void * __constant_memcpy(void * to, const void * from, size_t n) +static always_inline void * __constant_memcpy(void * to, const void * from, size_t n) { switch (n) { case 0: @@ -272,12 +272,13 @@ __asm__ __volatile__( \ } #define __HAVE_ARCH_MEMCPY - -#define memcpy(t, f, n) \ -(__builtin_constant_p(n) ? \ - __constant_memcpy((t),(f),(n)) : \ - __memcpy((t),(f),(n))) - +static always_inline __attribute_used__ +void memcpy(void *t, const void *f, size_t n) +{ + (__builtin_constant_p(n) ? + __constant_memcpy((t),(f),(n)) : + __memcpy((t),(f),(n))); +} /* * struct_cpy(x,y), copy structure *x into (matching structure) *y. @@ -410,7 +411,7 @@ return __res; * This looks horribly ugly, but the compiler can optimize it totally, * as we by now know that both pattern and count is constant.. */ -static inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count) +static always_inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count) { switch (count) { case 0: -- 2.30.2